#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QPixmap>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkSession>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkCookie>
#include <QTextDocument>
#include <QTextDecoder>
#include <QTextCodec>
#include <QFile>
#include <QDir>
#include <QStandardPaths>
#include <QDataStream>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

struct Book{
    QString author;
    QString name;
    QString id;
    QString time_begin;
    QString time_end;
    QString url;
};

class Widget : public QWidget
{
    Q_OBJECT
public slots:
    void requestFinished(QNetworkReply* reply);
public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
public:
    static QString GetSubString(QString src, QString pattern);
    static QStringList GetSubStringEX(QString src, QString pattern);
    static QString Unescape(QString src);
    static QString MD5(QByteArray data);
    void SendRequest(QString url,QString data="");
    static QString AutoDecode(QByteArray data);
    static QString GetSaveFile();
    void Save(QDataStream &ds);
    void Load(QDataStream &ds);
    void RefreshBooksDisplay();
private slots:
    void on_pushButton_clicked();
    void on_pushButton_2_clicked();
    void on_checkBox_2_stateChanged(int arg1);

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_tabWidget_currentChanged(int index);

private:
    Ui::Widget *ui;
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    QString csrf;
    QString name;
    bool first = true;
    QList<Book> books;
};
#endif // WIDGET_H
